import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect: '/login',
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../Views/login/loginPage.vue'),
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('../Views/login/register.vue'),
  },
  {
    path: '/',
    component: () => import('../views/HomePage.vue'), // 其他页面使用布局组件
    children: [
      {
        path: '/courselist',
        name: 'courselist',
        component: () => import('../views/Course/CourseList.vue'),
      },
      {
        path: '/userHub',
        name: 'userHub',
        component: () => import('../views/User/userHub.vue'),
        children: [
          {
            path: '/userHub/userInfo',
            name: 'userInfo',
            component: () => import('../views/User/userInfo.vue')
          },
          {
            path: '/userHub/modifyUserInfo',
            name: 'modifyUserInfo',
            component: () => import('../views/User/modifyUserInfo.vue')
          },
          {
            path: '/userHub/userFav',
            name: 'userFav',
            component: () => import('../views/User/userFav.vue')
          },
          {
            path: '/userHub/userPublish',
            name: 'userPublish',
            component: () => import('../views/User/userPublish.vue')
          },
          {
            path: '/userHub/publish',
            name: 'publish',
            component: () => import('../views/User/publishVideo.vue')
          },
        ]
      },
      {
        path: '/videoDetail/:id',
        name: 'videoDetail',
        component: () => import('../views/Video/videoDetail.vue')
      },
    ],
  },
]
const router = createRouter({
  history: createWebHistory('wyj'),
  routes,
})
export default router
